//
//  PurchaseDetail.swift
//
//  Created by Zwb on 29/01/2018
//  Copyright (c) aowang. All rights reserved.
//

import Foundation
import ObjectMapper

// s_goods_id:商品ID id_key:订单细表ID s_goods_nm:商品名称，s_piece_value_t:确认重量，s_money:金额 ，s_exe_amount:已入库数量，s_goods_type:商品类别 vou_id:主表ID ，s_amount_t:确认数量，s_goods_spec:规格，s_amount_z:赠包，s_money_t:确认金额 s_cess_price:单价，s_piece_value:重量，s_goods_bz:标包 s_goods_unit:规格 s_goods_code:商品代码

public struct ZyaPurchaseDetail: Mappable {

  // MARK: Declaration for string constants to be used to decode and also serialize.
  private struct SerializationKeys {
    static let sExeAmount = "s_exe_amount"
    static let sPieceValue = "s_piece_value"
    static let sGoodsCode = "s_goods_code"
    static let sGoodsId = "s_goods_id"
    static let sPieceValueT = "s_piece_value_t"
    static let vouId = "vou_id"
    static let sCessPrice = "s_cess_price"
    static let sMoney = "s_money"
    static let sMoneyT = "s_money_t"
    static let sAmountZ = "s_amount_z"
    static let sGoodsSpec = "s_goods_spec"
    static let idKey = "id_key"
    static let sGoodsBz = "s_goods_bz"
    static let sGoodsType = "s_goods_type"
    static let sAmountT = "s_amount_t"
    static let sGoodsNm = "s_goods_nm"
    static let sGoodsUnit = "s_goods_unit"
  }

  // MARK: Properties
  public var sExeAmount: String?
  public var sPieceValue: String?
  public var sGoodsCode: String?
  public var sGoodsId: String?
  public var sPieceValueT: String?
  public var vouId: String?
  public var sCessPrice: String?
  public var sMoney: String?
  public var sMoneyT: String?
  public var sAmountZ: String?
  public var sGoodsSpec: String?
  public var idKey: String?
  public var sGoodsBz: String?
  public var sGoodsType: String?
  public var sAmountT: String?
  public var sGoodsNm: String?
  public var sGoodsUnit: String?

  // MARK: ObjectMapper Initializers
  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public init?(map: Map){

  }

  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  mutating public func mapping(map: Map) {
    sExeAmount <- map[SerializationKeys.sExeAmount]
    sPieceValue <- map[SerializationKeys.sPieceValue]
    sGoodsCode <- map[SerializationKeys.sGoodsCode]
    sGoodsId <- map[SerializationKeys.sGoodsId]
    sPieceValueT <- map[SerializationKeys.sPieceValueT]
    vouId <- map[SerializationKeys.vouId]
    sCessPrice <- map[SerializationKeys.sCessPrice]
    sMoney <- map[SerializationKeys.sMoney]
    sMoneyT <- map[SerializationKeys.sMoneyT]
    sAmountZ <- map[SerializationKeys.sAmountZ]
    sGoodsSpec <- map[SerializationKeys.sGoodsSpec]
    idKey <- map[SerializationKeys.idKey]
    sGoodsBz <- map[SerializationKeys.sGoodsBz]
    sGoodsType <- map[SerializationKeys.sGoodsType]
    sAmountT <- map[SerializationKeys.sAmountT]
    sGoodsNm <- map[SerializationKeys.sGoodsNm]
    sGoodsUnit <- map[SerializationKeys.sGoodsUnit]
  }

  /// Generates description of the object in the form of a NSDictionary.
  ///
  /// - returns: A Key value pair containing all valid values in the object.
  public func dictionaryRepresentation() -> [String: Any] {
    var dictionary: [String: Any] = [:]
    if let value = sExeAmount { dictionary[SerializationKeys.sExeAmount] = value }
    if let value = sPieceValue { dictionary[SerializationKeys.sPieceValue] = value }
    if let value = sGoodsCode { dictionary[SerializationKeys.sGoodsCode] = value }
    if let value = sGoodsId { dictionary[SerializationKeys.sGoodsId] = value }
    if let value = sPieceValueT { dictionary[SerializationKeys.sPieceValueT] = value }
    if let value = vouId { dictionary[SerializationKeys.vouId] = value }
    if let value = sCessPrice { dictionary[SerializationKeys.sCessPrice] = value }
    if let value = sMoney { dictionary[SerializationKeys.sMoney] = value }
    if let value = sMoneyT { dictionary[SerializationKeys.sMoneyT] = value }
    if let value = sAmountZ { dictionary[SerializationKeys.sAmountZ] = value }
    if let value = sGoodsSpec { dictionary[SerializationKeys.sGoodsSpec] = value }
    if let value = idKey { dictionary[SerializationKeys.idKey] = value }
    if let value = sGoodsBz { dictionary[SerializationKeys.sGoodsBz] = value }
    if let value = sGoodsType { dictionary[SerializationKeys.sGoodsType] = value }
    if let value = sAmountT { dictionary[SerializationKeys.sAmountT] = value }
    if let value = sGoodsNm { dictionary[SerializationKeys.sGoodsNm] = value }
    if let value = sGoodsUnit { dictionary[SerializationKeys.sGoodsUnit] = value }
    return dictionary
  }

}
